import request from "@/utils/request";

const LOG_BASE_URL = "/v3/data/bms";

class BmscontrolApi {
  static getPropertyByGroupId(Params: controlBMSTo) {
    return request<any, PropertyByGroup[]>({
      url: `${LOG_BASE_URL}/getPropertyByGroupId`,
      method: "get",
      params: Params,
    });
  }

  static deviceHistoricalData(data: DeviceHistoricalDataParams) {
    return request<any, getParametertype>({
      url: `${LOG_BASE_URL}/deviceHistoricalData`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: data,
    });
  }

  static detection(Params: controlBMS) {
    return request<any, detectionBMS[]>({
      url: `${LOG_BASE_URL}/detection`,
      method: "post",
      params: Params,
    });
  }

  static curveOfTheDay(data: curveOfTheDayOV) {
    return request<any, curveOfThedata>({
      url: `${LOG_BASE_URL}/curveOfTheDay`,
      headers: {
        "Content-Type": "application/json",
      },
      method: "post",
      data: data,
    });
  }
}

export default BmscontrolApi;

/**
 * 分页VO
 */
export interface LogPageVO {
  current: number;
  pages: number;
  dataList: Array<any>;
  size: number;
  total: number;
}

interface getParametertype {
  data: LogPageVO;
  headers: [
    {
      pointCode: string;
      name: string;
    },
  ];
}
export interface DeviceHistoricalDataParams {
  /* */
  pages: {
    /* */
    current: number;

    /* */
    size: number;
    total: number;

    /* */
    startTime?: string;

    /* */
    endTime?: string;

    /* */
    orders?: {
      /* */
      column?: string;

      /* */
      asc?: boolean;
    }[];
  };

  /* */
  deviceId?: string;

  /* */
  pointGroupId?: string;
}

export interface PropertyByGroup {
  pointId: string;
  pointCode: string;
  pointName: string;
  type: string;
  value: string;
  content: any;
}

export interface controlBMSTo {
  groupId: number;
  deviceId: number;
}

export interface controlBMS {
  deviceCode: string;
  // pointGroupIdList: string[];
}

export interface detectionBMS {
  data: parameter[];
  type: string;
}
export interface bmsData {
  data: parameter[];
}
export interface parameter {
  headers: parameterData[];
  lastUpdateTime: string;
  pointGroupId: string | number;
  pointGroupName: string;
}
export interface parameterData {
  data?: string;
  fileId: string;
  name: string;
  unit?: string;
  type?: string;
  isMax?: boolean;
  isMin?: boolean;
}

export interface curveOfTheDayOV {
  deviceCode: string;
  startTime?: string;
  endTime?: string;
}
export interface curveOfThedata {
  data: any;
  time: string[];
}
